package com.chii.user.service.impl;

import com.chii.user.mapper.RoleMapper;
import com.chii.user.po.Role;
import com.chii.user.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public int insert(String roleName, String roleDescription) {
        Role role = new Role();
        role.setRoleName(roleName);
        role.setRoleDescription(roleDescription);
        return roleMapper.insertSelective(role);
    }

    @Override
    public Role getRole(String roleName) {
        return roleMapper.selectByRoleName(roleName);
    }

    @Override
    public List<Role> getByUserId(int userId) {
        return roleMapper.selectByUserId(userId);
    }
}
